#/bin/bash -x
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit linux-mod

MY_PV=${PV/_pre[0-9]*}
BUILD=${PV/[0-9,.]*_pre}
VERSION=${PR/[r]}
DESCRIPTION="NDAS kernel modules"
HOMEPAGE="http://code.ximeta.com/trac-ndas/wiki/Gentoo"
SRC_URI="http://code.ximeta.com/dev/current/linux64/ndas-1.1-24.x86_64.tar.gz"

LICENSE="ximeta"
SLOT="0"
KEYWORDS="~amd64"
IUSE=""

DEPEND="virtual/linux-sources"

MODULE_NAMES="ndas_block(kernel/drivers/block/ndas:) ndas_core(kernel/drivers/block/ndas:) ndas_sal(kernel/drivers/block/ndas:)" 

S="${WORKDIR}/${PN}-${MY_PV}-${VERSION}"

src_compile() {
	set_arch_to_kernel
	cd ${S}
	epatch "${FILESDIR}/Linux2.6.27.patch"
	emake || die "emake failed."
}

src_install() {
	linux-mod_src_install

	insinto ${DESTTREE}/share/ndas
	insopts -m755
	doins mknod.sh ndas

	insinto /etc/init.d
	insopts -m755
	newins ndas.gentoo ndas

	dosbin ndasadmin

	dodoc README INSTALL
}

pkg_postinst () {
	linux-mod_pkg_postinst
	rc-update add ndas default
}
